{extend name="public/base"}

{block name="main"}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户中心 <span class="c-gray en">&gt;</span> 会员列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="cl pd-5 bg-1 bk-gray">
            <span class="l">
                <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
                    <i class="Hui-iconfont">&#xe6e2;</i> 批量删除
                </a>
                <a href="javascript:;" onclick="layer_show('添加分类','{:url("save_category")}','0','0')" class="btn btn-primary radius">
                    <i class="Hui-iconfont">&#xe600;</i> 添加分类
                </a>
            </span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" name="" value=""></th>
                    <th width="80">ID</th>
                    <th width="100">分类名</th>
                    <th width="100">图片</th>
                    <th width="100">状态</th>
                    <th width="100">排序</th>
                    <th width="100">首页显示</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr class="text-c">
                    <td><input type="checkbox" value="{$vo.id}" name=""></td>
                    <td>{$vo.id}</td>
                    <td class="text-l">{$vo.level|str_repeat=' --- ', ###}{$vo.name}</td>
                    <td class="text-l">
                        <a title="编辑" href="javascript:;" onclick="layer_show('设置图片','{:url("set_image", ["id" => $vo['id']])}','0','0')">
                            {empty name="vo.image"} 未设置 {else /} <img src="__PUBLIC__{$vo.image}" style="max-width: 120px;" /> {/empty}
                        </a>
                    </td>
                    <td class="td-status">{$vo.status|get_list_status_html=$vo.id,'category'}</td>
                    <td class="td-status"><input type="text" class="sort" value="{$vo.sort}" data-id="{$vo.id}" data-default-sort="{$vo.sort}"></td>
                    <td class="td-status">{$vo.index|get_list_index_status_html=$vo.id,'category'}</td>
                    <td class="td-manage">
                        <a title="编辑" href="javascript:;" onclick="layer_show('编辑管理员','{:url("save_category", ["id" => $vo['id']])}','0','0')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                        <a title="删除" data-href="{:url('common/save_model_field', ['id' => $vo['id'], 'field' => 'delete', 'value' => 1, 'model' => 'category'])}" class="ml-5 delete" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </article>
</div>
{/block}

{block name="javascript"}
<script>
    $(function () {
       $('.sort').blur(function () {
           $("#loading").show();
           var _this = $(this);
           if (_this.val() == _this.data('default-sort')) {
               $("#loading").hide();
               return false;
           }
           $.ajax({
               type : 'post',
               url : '{:url("sort")}',
               data : {
                   id : _this.data('id'),
                   sort : _this.val()
               },
               dataType : 'json',
               success : function (msg) {
                   layer.msg(msg.msg, {icon: 6,time:1000});
                   $("#loading").hide();
               }
           });
       });
    });
</script>
{/block}